package org.example.java8.localDate;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
/**
 * java.time.LocalDate:
 * LocalDate只提供日期，不提供时间信息。它是不可变类且线程安全的。
 *
 * This class demonstrates JAVA 8 data and time API
 *
 * @author Siva Prasad Rao Janapati
 */
public class LocalDateDemonstration {
    /**
     * @param args
     */
    public static void main(String[] args) {

        //Create date
        LocalDate localDate = LocalDate.now();
        System.out.println("The local date is :: " + localDate);
        //Find the length of the month. That is, how many days are there for this month.
        System.out.println("The number of days available for this month:: " + localDate.lengthOfMonth());
        //Know the month name
        System.out.println("What is the month name? :: " + localDate.getMonth().name());
        //add 2 days to the today's date.
        System.out.println(localDate.plus(2, ChronoUnit.DAYS));
        //substract 2 days from today
        System.out.println(localDate.minus(2, ChronoUnit.DAYS));
        //Convert the string to date
        //System.out.println(localDate.parse("2017-04-07"));
        LocalDate localDate1 = LocalDate.parse("2017-04-07");
        System.out.println(localDate1);
    }

}